import { Component } from "react";
import { lcFirst, camelCaseToSnakeCase } from "../../common/function/stringFunc";
import { getClsName } from "../../common/function/objFunc";

export namespace ReactComponent {
    export interface Props {
        className?: string;
    }

    export interface State {

    }
}

export class ReactComponent<P extends ReactComponent.Props = {}, S extends ReactComponent.State = {}> extends Component<P, S> {
    public getBaseClsName() {
        return camelCaseToSnakeCase(lcFirst(getClsName(this)));
    }
    public getClsName(clsName: string = "") {
        const baseName = " react-component " + clsName;
        if (this.props.className) {
            return this.props.className + " " + baseName;
        }
        return baseName;
    }
}
